package com.study.ioc.demo.label;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.w3c.dom.Element;


public class MyLabelParser2 extends AbstractSingleBeanDefinitionParser {

    @Override
    protected Class getBeanClass(Element element) {
        //代表Bean的类为MyLabel2.class
        return MyLabel2.class;
    }

    @Override
    protected void doParse(Element element, BeanDefinitionBuilder builder) {
        //解释如何从Element对象解析成Bean的对象
        Integer id = Integer.parseInt(element.getAttribute("id"));
        String code = element.getAttribute("code");

        builder.addPropertyValue("id", id);
        builder.addPropertyValue("code", code);
    }
}
